package cn.ivast.recyclerviewtest;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

import cn.ivast.recyclerviewtest.R;
import cn.ivast.recyclerviewtest.adapter.StringAdapter;
import cn.ivast.recyclerviewtest.decoration.MyDecoration;

public class MyDecorationActivity extends AppCompatActivity {

    RecyclerView recyclerView;
    StringAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_decoration);
        recyclerView = findViewById(R.id.recyclerView);

        adapter = new StringAdapter(recyclerView);
        List<String> datas = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            datas.add("我是数据-->" + i);
        }
        adapter.setData(datas);
        LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerView.addItemDecoration(new MyDecoration(5));
        recyclerView.setLayoutManager(manager);
        recyclerView.setAdapter(adapter);
    }
}
